package com.yjps.company.service;

import com.yjps.company.dao.NewsDao;
import com.yjps.company.model.News;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * Created by 麒全 on 2015/8/18.
 */
@Service
public class NewsService {
    Logger log = LoggerFactory.getLogger(NewsService.class);
    @Autowired
    NewsDao newsDao;

    public void update (News news){
        String hql = "update News n set n.content =:content and n.title =:title where n.id =:id";
        Map<String,Object> params = new HashMap<>();
        params.put("content",news.getContent());
        params.put("title",news.getTitle());
        params.put("id",news.getId());
        newsDao.excute(hql,params);
        log.debug("update the news success, id is " + news.getId());
    }
}
